package com.foreverwin.jzymes.report.cpk.controller;


import com.foreverwin.jzymes.common.service.ISiteAdviceService;
import com.foreverwin.jzymes.common.util.CommonMethods;
import com.foreverwin.jzymes.framework.base.AjaxResult;
import com.foreverwin.jzymes.framework.exception.BusinessException;
import com.foreverwin.jzymes.report.cpk.service.ICPKReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/report/cpk")
public class CPKReportController {

    @Autowired
    ISiteAdviceService siteAdviceService;
    @Autowired
    ICPKReportService cpkReportService;

    @RequestMapping("/cpkReport")
    public AjaxResult cpkReport(@RequestParam Map<String , Object> jsonMap){
        String site = CommonMethods.getSite();
        siteAdviceService.existSite( site );
        try{
            jsonMap.put("site", site );
            List<Map<String,Object>> rtnList = cpkReportService.findCPKByReport( jsonMap );
            return AjaxResult.returnSuccess().put("value",rtnList);
        }catch ( BusinessException e ){
            return AjaxResult.returnError( e.getMessage() );
        }
    }
}
